#include "Connection.h"
#include "PublicUtils.h"

// 初始化socket
int SocketDriver(int *socket_fd){
    *socket_fd = socket(AF_INET, SOCK_STREAM, 0);
	

    char *ip = getIpFromConfig();
    char *port = getPortFromConfig();

	struct sockaddr_in addr;
	addr.sin_family = AF_INET;
	addr.sin_port = htons(atoi(port));
	addr.sin_addr.s_addr = inet_addr(ip);

	int ret_bind = connect(*socket_fd, (struct sockaddr*)&addr, sizeof addr);
	if(ret_bind == -1){
		printf("连接已丢失\n");
	}

    free(ip);
    free(port);

	return 0;
}

